package com.itheima.a01polymorphismdemo2;

public class Test {
    public static void main(String[] args) {
        Dog dog = new Dog("黑",2);
        Cat cat = new Cat("灰",3);
        keepPet(dog,"骨头");
        keepPet(cat,"鱼");

    }

    public static void keepPet(Animal animal , String food){
        if(animal instanceof Dog){
            Person a = new Person("老王",30);
            a.keepPet(animal,"骨头");
        }else if(animal instanceof Cat){
            Person b = new Person("老李",25);
            b.keepPet(animal,"鱼");
        }

    }

}

